package org.example.query;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
public class DepartmentQuery extends BaseQuery{
    private String deptCode;
    private String deptName;
    private String deptType;

    @Override
    public Wrapper getQueryWrapper() {
        MPJLambdaWrapper queryWarpper = new MPJLambdaWrapper();
        //这里没有弄联查
        if(StringUtils.isNotEmpty(deptCode)) {
            queryWarpper.likeRight("dept_code", deptCode);
        }
        if(StringUtils.isNotEmpty(deptName)) {
            queryWarpper.likeRight("dept_name", deptName);
        }
        if(StringUtils.isNotEmpty(deptType)) {
            queryWarpper.likeRight("dept_type", deptType);
        }
        queryWarpper.orderByDesc("id");
        return queryWarpper;
    }
}
